<?php

namespace app\admin\validate\file;

use tmcore\base\BaseValidate;

/**
 * 导出导入验证器
 */
class ExportValidate extends BaseValidate
{
    protected $rule = [
        'page_limit'  => 'require|number',
        'is_page'     => 'require|in:0,1',
        'is_async'    => 'require|in:0,1',
        'export_type' => 'require|in:1,2',
        'file'        => 'file'
    ];

    protected $message = [
        'page_limit.require'  => '缺少page_limit参数',
        'page_limit.number'   => 'page_limit参数有误',
        'is_page.require'     => '缺少is_page参数',
        'is_page.in'          => 'is_page参数有误',
        'is_async.require'    => '缺少is_async参数',
        'is_async.in'         => 'is_async参数有误',
        'export_type.require' => '缺少export_type参数',
        'export_type.in'      => 'export_type参数有误',
        'file.file'           => '缺少file参数',
    ];

    /**
     * 导出场景
     * @return ExportValidate
     */
    public function sceneExport()
    {
        return $this->only(['page_limit', 'is_page', 'is_async', 'export_type']);
    }

    /**
     * 导入场景
     * @return ExportValidate
     */
    public function sceneImport()
    {
        return $this->only(['file']);
    }
}